package com.ajream.controller;

import com.ajream.entity.Student;
import com.ajream.service.impl.StudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@ResponseBody
public class GetStudentInfoController {
    @Resource
    StudentServiceImpl service;

    @RequestMapping("/")
    public String index(){
        return "<h1>这是主页</h1>";
    }

//    RESTFul风格的url路径
    @RequestMapping("/hello/{p}")
    public String hello(@PathVariable String p){
        return "hello " + p;
    }

    @RequestMapping("/student_info/{sid}")
    public Student studentInfo(@PathVariable String sid){
        return service.findBySid(sid);
    }

    @RequestMapping("/student_info/all")
    public List<Student> findAllStudents(){
        return service.findAll();
    }

}
